package com.enmotech.kafkatest.controller;

import org.springframework.stereotype.Component;

import java.io.*;

/**
 * com.enmotech.kafkatest.controller
 *
 * @author syf
 * @create 2022-08-19-10:13
 * @Description 生成schema
 */
@Component
public class SchemaDemo {
    private String schema;
    //默认表结构
    public String getSchema() {
        File file = null;
        StringBuilder sb = new StringBuilder();
        BufferedReader bfr = null;
        FileReader fr = null;

        try {
            file = new File("test.json");
            fr = new FileReader(file);
            bfr = new BufferedReader(fr);
            String data = null;
            while ((data = bfr.readLine())!=null){
                sb.append(data);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        schema = sb.toString();
        //去掉读取到的字符串中的空格
        schema = schema.replace(" ","");
        return schema;
    }

    //指定表结构
    public String getSchema(String[] files){
        return schema;
    }
}
